@extends('layouts.console_header')

@section('title', '地推已提现')

@section('resources')
    @parent
    <style>
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
        .salesman_type{background-color: #fff;overflow: hidden;}
        .salesman_type span{padding: 10px 30px;margin: 20px 10px 0 10px;float: left;cursor: pointer;}
        .salesman_type_show{border-bottom: 3px solid #9955c6;color: #9955c6;}
    </style>
@endsection

@section('content')
<!--  html内容  -->
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>财务中心></span>
		    <span class="co_violet">地推已提现</span>
		</p>
		<a href="#" onclick="export_data()"><p class="fr tc back_btn">导出</p></a>
	</div>
    <p class="salesman_type">
        <span><a href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&salesmantype=shopsalesman">商家地推</a></span>
        <span><a href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&salesmantype=usersalesman">个人地推</a></span>
    </p>
    @if($salesmantype == 'shopsalesman')
        <div class="salesman_shop">
        <nav>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=today&salesmantype=shopsalesman">今日</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=yesterday&salesmantype=shopsalesman">昨日</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=week&salesmantype=shopsalesman">本周</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=thismonth&salesmantype=shopsalesman">本月</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=lastmonth&salesmantype=shopsalesman">上月</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=all&salesmantype=shopsalesman">全部</a>
            <span class="fl">时段选择</span>
            <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
            <span class="fl">至</span>
            <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
        </nav>
        <span class="finance_top_list"> 合计：{{$count}}笔已提现数据 提现金额：¥{{($sum=='')?0.00:$sum}}</span>

        <table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>商家代码</th>
                    <th>商家名称</th>
                    <th>持卡人</th>
                    <th>银行卡号</th>
                    <th>银行名称</th>
                    <th>开户行所在地</th>
                    <th>开户行名称</th>
                    <th>提现日</th>
                    <th>提现金额(元)</th>
                    <th>备注</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>序号</th>
                    <th>商家代码</th>
                    <th>商家名称</th>
                    <th>持卡人</th>
                    <th>银行卡号</th>
                    <th>银行名称</th>
                    <th>开户行所在地</th>
                    <th>开户行名称</th>
                    <th>提现日</th>
                    <th>提现金额(元)</th>
                    <th>备注</th>
                </tr>
            </tfoot>
            <tbody>
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['shopcode']}}</td>
                    <td>{{$list['shopname']}}</td>
                    <td>{{$list['cardholder']}}</td>
                    <td>{{$list['bankcard']}}</td>
                    <td>{{$list['bankname']}}</td>
                    <td>{{$list['bankprovince']}}-{{$list['bankcity']}}</td>
                    <td>{{$list['opencardbank']}}</td>
                    <td>{{date("Y-m-d H:i:s", strtotime($list['accounttime']))}}</td>
                    <td>{{$list['accountamount']}}</td>
                    <td>{{$list['remark']}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    @else
        <div class="salesman_user">
        <nav>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=today&salesmantype=usersalesman">今日</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=yesterday&salesmantype=usersalesman">昨日</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=week&salesmantype=usersalesman">本周</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=thismonth&salesmantype=usersalesman">本月</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=lastmonth&salesmantype=usersalesman">上月</a>
            <a class="fl" href="/console/finance/salesman/withdrawal/index?cityid={{$cityid}}&type=all&salesmantype=usersalesman">全部</a>
            <span class="fl">时段选择</span>
            <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
            <span class="fl">至</span>
            <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
        </nav>
        <span class="finance_top_list"> 合计：{{$count}}笔已提现数据 提现金额：¥{{($sum=='')?0.00:$sum}}</span>
        <table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>个人地推帐号</th>
                    <th>姓名</th>
                    <th>提现日</th>
                    <th>提现金额(元)</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>序号</th>
                    <th>个人地推帐号</th>
                    <th>姓名</th>
                    <th>提现日</th>
                     <th>提现金额(元)</th>
                </tr>
            </tfoot>
            <tbody>
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['mobile']}}</td>
                    <td>{{$list['name']}}</td>
                    <td>{{$list['accounttime']}}</td>
                    <td>{{$list['accountmoney']}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    @endif
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
    var cityid='{{$cityid}}';
    var salesmantype='{{$salesmantype}}';
    var str = window.location.href;
    if(str.indexOf("today") > 0){
        $("nav a").eq(0).css({"color": "#9955c6"});
    }else if(str.indexOf("yesterday") > 0){
        $("nav a").eq(1).css({"color": "#9955c6"});
    }else if(str.indexOf("week") > 0){
        $("nav a").eq(2).css({"color": "#9955c6"});
    }else if(str.indexOf("thismonth") > 0){
        $("nav a").eq(3).css({"color": "#9955c6"});
    }else if(str.indexOf("lastmonth") > 0){
        $("nav a").eq(4).css({"color": "#9955c6"});
    }else if(str.indexOf("all") > 0){
        $("nav a").eq(5).css({"color": "#9955c6"});
    }
    function select_date() {
        var startTime = $("input[name='starttime']").val();
        var lastTime = $("input[name='lasttime']").val();
        if(!startTime || !lastTime) {
            alert('请选择开始时间和结束时间'); return;
        }
        window.location.href="/console/finance/salesman/withdrawal/index?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime+"&salesmantype="+salesmantype;
    }
    function export_data() {
        var startTime = $("input[name='starttime']").val();
        var lastTime = $("input[name='lasttime']").val();
        if(!startTime || !lastTime) {
            alert('请选择开始时间和结束时间'); return;
        }
        window.open("/console/finance/salesman/withdrawal/export?cityid="+cityid+"&starttime="+startTime+"&lasttime="+lastTime+"&salesmantype="+salesmantype, '_blank');
    }
    if(salesmantype == 'usersalesman'){
        $(".salesman_type span").eq(1).addClass("salesman_type_show");
    }else{
        $(".salesman_type span").eq(0).addClass("salesman_type_show");
    }
    </script>
@endsection